﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SQLite;
using NHibernate;
using NHibernate.Cfg;
using OBSwindles;
using System.Collections;

namespace DASwindles
{
    public class LoginData : IDataManager
    {
        public LoginData()
        {

        }


        #region IDataManager Members

        public IList getDetails()
        {
            IList loginList = null;
            ISession session = DAHelper.getSession();
            loginList = session.CreateCriteria(typeof(Login)).List();
            return loginList;
        }

        public object getDetails_ByID(int p_ID)
        {
            IList loginList = null;
            ISession session = DAHelper.getSession();
            loginList = session.CreateCriteria(typeof(Login)).List();
            if (loginList != null)
            {
                for (int i = 0; i < loginList.Count; i++)
                {
                    Login login = (Login)loginList[i];
                    if (login.LoginID == p_ID)
                    {
                        return login;
                    }
                }

            }
            return null;
        }

        public void updateDetails(object p_Object)
        {
            ISession session = DAHelper.getSession();
            session.Update(p_Object);
        }

        public int insertDetails(object p_Object)
        {
            ISession session = DAHelper.getSession();
            session.Save(p_Object);
            return ((Login)p_Object).LoginID;
        }

        #endregion
    }
}
